import { App,Group } from "leafer-ui";
import useHistoryUtil from "../hooks/useHistoryUtil";
import { ComputedRef, Ref } from "vue";

export interface IToolConfig {
  pen: {
    color: string;
    strokeWidth: number;
    opcity: number;
  };
  eraser: {
    size: number;
  };
  text: {
    fontSize: number;
  };
  shape: {
    fill: string;
    stroke: string;
    strokeWidth: number;
    type: "rect" | "circle" | "polygon";
  };
}
export type IToolReturn = {
  eventsMap: Record<string, (event: any) => void>;
  active: () => void;
  deactive: () => void;
};
export interface IUseHistoryUtil<T> {
  data: Ref<T | undefined>;
  init: (initialData: T) => void;
  commit: (data: T) => void;
  redo: () => void;
  undo: () => void;
  canRedo: ComputedRef<boolean>;
  canUndo: ComputedRef<boolean>;
  index: Ref<number>;
  getCloneData: () => T;
  getHistoryList: () => T[];
}
export type ITool = (options: {
  app: App;
  config: IToolConfig;
  historyUtil: IUseHistoryUtil<Record<string, any>>;
  box:Group;
}) => IToolReturn;
